function AllReady() {
	const mstform = Ext.getCmp("PayPlanPc");

	//根据项目过滤合同
	//主表通用帮助过滤
	mstform
		.getItem("user_cnt_id")
		.on("beforetriggerclick", function (eOp, ignoreBeforeEvent) {
			return cntMFilter();
		});
	mstform
		.getItem("user_cnt_id")
		.on("helpselected", function (eOp, ignoreBeforeEvent) {
			getCntCz();
			getCntMInfoByPhid();
			getIncomeInspectionSum();
		});
	mstform
		.getItem("PhidPc")
		.on("helpselected", function (eOp, ignoreBeforeEvent) {
			getPcAccInfo();
            //获取合同数量
    getCntCount(()=>{
        getCntCz();
			getCntMInfoByPhid();
			getIncomeInspectionSum();
    })
		});
	function cntMFilter() {
		var PhidPc = mstform.getItem("PhidPc").getValue();
		if (!(Number(PhidPc) || 0)) {
			Ext.Msg.alert("提示", "请先选择项目！");
			mstform.getItem("PhidPc").focus();
			return false;
		} else {
			mstform.getItem("user_cnt_id").setOutFilter({
				phid_pc: PhidPc, //phid_pc 字段是通用帮助中的字段
				bill_type: 1,
			});
			return true;
		}
	}
	//获取合同产值
	function getCntCz() {
		if (!mstform.getItem("user_cnt_id").getValue()) return;
		console.log(mstform.getItem("user_cnt_id").getValue());
		execServer(
			"getCntCz",
			{ phid_cnt: mstform.getItem("user_cnt_id").getValue() },
			(res) => {
				console.log(res);
				if (res.count == 0) return;
				const _data = JSON.parse(res.data)[0].extendObjects;
				console.log(_data);
				mstform.getItem("user_cnt_cz").setValue(_data.amt_sum);
			}
		);
	}

	function getCntMInfoByPhid() {
		// BatchBindCombox([user_regional_center])
		execServer(
			"getCntMInfoByPhid",
			{ phid: mstform.getItem("user_cnt_id").getValue() },
			function (res) {
				const datas = JSON.parse(res.data)[0].extendObjects;
				console.log(datas);
				mstform.getItem("user_cnt_amt").setValue(datas.cnt_sum_vat_fc);
			}
		);
	}

	function getIncomeInspectionSum() {
		execServer(
			"getIncomeInspectionSum",
			{ phid_pc: mstform.getItem("PhidPc").getValue() },
			function (res) {
				const datas = JSON.parse(res.data)[0].extendObjects;
				console.log(datas);
				mstform.getItem("user_cnt_srby").setValue(datas.u_by_amt);
			}
		);
	}
	function getPcAccInfo() {
		execServer(
			"getPcAccInfo",
			{ phid_pc: mstform.getItem("PhidPc").getValue() },
			(res) => {
                console.log('获取内连账户信息',res);
				if (res.count == 0) return;
				const _data = JSON.parse(res.data)[0].extendObjects;
				const PhidInnerAcc = mstform.getItem("PhidInnerAcc");
				PhidInnerAcc.setValue(_data.phid_acc);
				BatchBindCombox([PhidInnerAcc]);
			}
		);
	}
    //获取合同数量
    getCntCount(()=>{
        getCntCz();
			getCntMInfoByPhid();
			getIncomeInspectionSum();
    })
function getCntCount(fun){
    if(!mstform.getItem("PhidPc").getValue()) return
    execServer("getCntCount",{type:1,phid_pc:mstform.getItem("PhidPc").getValue()},(res)=>{
      console.log(res,'count');
      switch(res.count){
        case 0:
          return
        case 1:
            const _data = JSON.parse(res.data)[0].extendObjects
            mstform.getItem("user_cnt_id").setValue(_data.phid)
            BatchBindCombox([mstform.getItem("user_cnt_id")])
            setTimeout(()=>{
                if(fun){
                  fun()
                }
              },200)
      }
    })
  }
}
